package testSudoku;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

import org.junit.Test;

import sudoku.Board;
import sudoku.Manager;
import sudoku.Sudoku_Question;
import sudoku.Validator;
import sudoku.easy_qustion;


public class testManager 
{
	// Test case 1: test class "Manager": the hint number >0
	@Test
	public void testHintNum() 
	{
		Manager manager =new Manager();	
		boolean result;
		result = manager.hint_ava();
		assertEquals(result, true);
	}
	
	// Test case 2: test class "Manager": test the number of step by 1
	// now step is 2, 
	@Test
	public void testIncreaseHintNumber() 
	{
		Manager manager =new Manager();	
		int result;
		int step=2;
		result = manager.count_step(step);
		manager.show_step(step);
		assertEquals(result,3);
	}
	
	// Test case 3: test class "Manager": use the parameter constructor of Manager
	//the hint number >0
	@Test
	public void testHintNum2() 
	{
		Manager manager =new Manager(1,1);	
		
		boolean result;
		result = manager.hint_ava();
		assertEquals(result, true);
		
	}
		
	
	// Test case 4: test class "Manager": use the parameter constructor of Manager
	//test the number of step by 1
	@Test
	public void testIncreaseHintNumber2() 
	{
		Manager manager =new Manager(2,1);	
		int result;
		int step=2;
		result = manager.count_step(step);
		assertEquals(result,3);
	}
		
	// Test case 5: test class "Manager": test copying question object and the number of step by 1
	// now step is 2, 
	@Test
	public void testcopying_question_object() 
	{
		
		 class Sudoku_QuestionStub implements Sudoku_Question{
           
			@Override
			public char[][][] get_questn() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][][] get_sol() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][] get_question(int qnum) {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][] get_solution(int qnum) {
				// TODO Auto-generated method stub
				return null;
			}
     };

    
     Sudoku_QuestionStub questionstub = new Sudoku_QuestionStub();
		Manager manager =new Manager(questionstub);	
		int result;
		int step=3;
		result = manager.count_step(step);
		assertEquals(result,4);
	}
	
	// Test case 6: test function is_invalid_length in class "Manager"
	@Test
	public void testis_invalid_length() 
	{
		class validatorStub extends Validator{
            @Override
        	public boolean is_invalid_length(String input)
        	{
        		
        			return true;
        	}
    };
    
		
    validatorStub validStub =new validatorStub();	
    Manager manager =new Manager();	
		boolean result;
	
		String input="as";
		result = manager.is_invalid_length(input);
		assertEquals(result,true);
	}

	// Test case 7: test function is_invalid_range in class "Manager"
	@Test
	public void testis_invalid_range() 
	{
		class validatorStub extends Validator{
            @Override
        	public boolean is_invalid_range(String input)
        	{
        		
        			return true;
        	}
    };
    
		
    validatorStub validStub =new validatorStub();	
    Manager manager =new Manager();	
		boolean result;
	
		String input="as";
		result = manager.is_invalid_range(input);
		assertEquals(result,true);
	}

	// Test case 8: test function contain_nonzero_position in class "Manager"
	@Test
	public void testcontain_nonzero_position() 
	{
		class validatorStub extends Validator{
            @Override
        	public boolean contain_nonzero_position(int xPos,int yPos)
        	{
        		
        			return true;
        	}
    };
    
		
    validatorStub validStub =new validatorStub();	
    Manager manager =new Manager();	
		boolean result;
	
		result = manager.contain_nonzero_position(2,2);
		assertEquals(result,true);
	}
			
	
	// Test case 9: test function is_invalid_value() in class "Manager"
	@Test
	public void testis_invalid_value() 
	{
		class validatorStub extends Validator{
            @Override
        	public boolean is_invalid_value(String input)
        	{
        		
        			return true;
        	}
    };
    
		
    validatorStub validStub =new validatorStub();	
    Manager manager =new Manager();	
		boolean result;
		String input="as";
	
		result = manager.is_invalid_value(input);
		assertEquals(result,true);
	}
	
	// Test case 10: test function gamewin() in class "Manager"
	@Test
	public void gamewin()
	{
		class Sudoku_QuestionStub implements Sudoku_Question{
	           
			@Override
			public char[][][] get_questn() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][][] get_sol() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][] get_question(int qnum) {
				// TODO Auto-generated method stub
				
				char[][] hard_sol = {
						
							{' ',' ','7','2','9','1','5','3','4'},
							{'4','1','9','5','8','3','2','6','7'},
							{'5','2','3','7',' ','4','8','9','1'},
							{'7','3','4','6','2','5','1','8','9'},
							{'9','8','6','3','1','7','4','5','2'},
							{'2','5','1','8',' ',' ','6','7','3'},
							{'6','9','2','1','7','8','3','4','5'},
							{'3','4','8','9','5','2','7','1','6'},
							{'1','7','5','4','3','6','9','2','8'}			
						};
					
				return hard_sol;
			}

			@Override
			public char[][] get_solution(int qnum) {
				// TODO Auto-generated method stub
				return null;
			}
     };

    
     Sudoku_QuestionStub questionstub = new Sudoku_QuestionStub();	
     Manager manager =new Manager(2,2);
		boolean result;
		
	
		result = manager.gamewin();
		assertEquals(result,false);
		
	}
	
	// Test case 11: test function gameover in class "Manager"
	@Test
	public void gameover()
	{
		class Sudoku_QuestionStub implements Sudoku_Question{
	           
			@Override
			public char[][][] get_questn() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][][] get_sol() {
				// TODO Auto-generated method stub
				return null;
			}

			@Override
			public char[][] get_question(int qnum) {
				// TODO Auto-generated method stub
				
				char[][] hard_sol = {
						
							{' ',' ','7','2','9','1','5','3','4'},
							{'4','1','9','5','8','3','2','6','7'},
							{'5','2','3','7',' ','4','8','9','1'},
							{'7','3','4','6','2','5','1','8','9'},
							{'9','8','6','3','1','7','4','5','2'},
							{'2','5','1','8',' ',' ','6','7','3'},
							{'6','9','2','1','7','8','3','4','5'},
							{'3','4','8','9','5','2','7','1','6'},
							{'1','7','5','4','3','6','9','2','8'}			
						};
					
				return hard_sol;
			}

			@Override
			public char[][] get_solution(int qnum) {
				// TODO Auto-generated method stub
				return null;
			}
     };

    
     Sudoku_QuestionStub questionstub = new Sudoku_QuestionStub();	
     Manager manager =new Manager(1,2);
		boolean result;
		
	
		result = manager.gameover();
		assertEquals(result,false);
		
	}
}
